#!/bin/sh

dir=release_data
vocdir=$dir/tovoc

# generate train.txt and val.txt
img_dir=$vocdir/JPEGImages
labels_dir=$vocdir/Annotations

img_count=$(ls $img_dir | wc -l)
echo "image count: $img_count"
train_count=$(echo "$img_count * 0.8" | bc)
train_count=${train_count%.*}
echo "train count: $train_count"

train_file=$vocdir/train.txt
val_file=$vocdir/val.txt
echo "" > $train_file
echo "" > $val_file
let count=0
for i in $(ls $img_dir); do
    prename=${i%.*}
    if [ $count -lt $train_count ]; then
        echo "JPEGImages/$i Annotations/$prename.xml" >> $train_file
    else
        echo "JPEGImages/$i Annotations/$prename.xml" >> $val_file
    fi
    let count=count+1
done